const router = require('koa-router')();
const argracefile = require('../../controller/argracefile/argracefile.controller');
const helper = require('../../util/helper');
const multer = require('koa-multer');

//配置
const storage = multer.diskStorage({
    //文件保存路径
    destination: function (req, file, cb) {
        helper.mkdirsSyncEx(__publicUploadPath);
        cb(null, __publicUploadPath)
    },
    //修改文件名称
    filename: function (req, file, cb) {
        var fileFormat = (file.originalname).split(".");
        cb(null,Date.now() + "." + fileFormat[fileFormat.length - 1]);
    }
})
//加载配置
const upload = multer({ storage: storage });

router.post('/',  upload.single('files1'),argracefile.save);

module.exports = router;